﻿@model FTBS.Models.Entities.Concert.ReportTube
@{
    ViewBag.Title = "Báo cáo hệ thống";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";

    var fromDate = (DateTime)ViewBag.FromDate;
    var toDate = (DateTime)ViewBag.ToDate;
}
<legend style="margin-top: 10px">THỐNG KÊ</legend>

<table class="table striped bordered hovered" style="font-weight: bold">
    <tr style="text-align: left; font-weight: bold">
        <th style="text-align: left">Đối tác :
        </th>
        <th>
            @Html.DropDownListFor(model => model.SupplierName, (SelectList)ViewBag.ListSupplier, "--- Chọn tất cả ---", new { value = "0", id = "cbbSupplier" })
        </th>
        <th style="text-align: left">Xem báo cáo theo :
        </th>
        <th>
            @Html.DropDownListFor(model => model.SupplierName, (SelectList)ViewBag.ViewMode, new { id = "cbbMode" })
        </th>
    </tr>
    <tr>
        <th style="text-align: left">Từ ngày:
        </th>
        <td>
            <div class="input-control text" data-role="datepicker"
                        data-date='@fromDate.ToShortDateString()'
                        data-format="dd/mm/yyyy"
                        data-position="bottom"
                        data-effect="slide"
                        data-other-days='1'>
                <input type="text" id="FromDate" name="FromDate">
                <button class="btn-date" type="button"></button>
            </div>
        </td>
        <th style="text-align: left">Đến ngày:
        </th>
        <td>
            <div class="input-control text" data-role="datepicker"
                        data-date='@toDate.ToShortDateString()'
                        data-format="dd/mm/yyyy"
                        data-position="bottom"
                        data-effect="slide"
                        data-other-days='1'>
                <input type="text" id="ToDate" name="ToDate">
                <button class="btn-date" type="button"></button>
            </div>
        </td>
    </tr>
    <tr id="alert" style="display:none">
        <td colspan="4" style="color:red; text-align:right; font-family:Arial; font-weight:100;">
            Ngày trong mục "Từ ngày" không được lớn hơn ngày trong mục "Đến ngày"!
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <input id="btnSubmit" class="info" type="submit" value="Xem báo cáo" />
        </td>
    </tr>
</table>
<script type="text/javascript">
    $(document).ready(function () {
        $("#alert").hide();
        $("#cbbSupplier option:first").attr("value", "0");
    })

    $("#btnSubmit").click(function () {
        var viewMode = $("#cbbMode").val()
        var supplier = $("#cbbSupplier").val();

        var fDate = $("#FromDate").val();
        var tDate = $("#ToDate").val();

        var fDateList = fDate.split("/");
        var tDateList = tDate.split("/");

        var fObject = new Date(fDateList[2], fDateList[1], fDateList[0]);
        var tObject = new Date(tDateList[2], tDateList[1], tDateList[0]);


        if (fObject.getTime() > tObject.getTime()) {
            $("#alert").show();
        }
        else {
            window.location.href = "AdminReportView?usn=" + supplier + "&viewMode=" + viewMode + "&fTime=" + fDate + "&tTime=" + tDate
        }
    })
</script>
